home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / authors.fr_ / authors.fr
Text File  |  1995-04-01  |  5KB  |  165 lines

  1. VERSION 4.00
  2. Begin VB.Form frmAuthors 
  3.    Caption         =   "Author Birth Range"
  4.    ClientHeight    =   1575
  5.    ClientLeft      =   1815
  6.    ClientTop       =   1515
  7.    ClientWidth     =   4185
  8.    Height          =   1980
  9.    Left            =   1755
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   1575
  12.    ScaleWidth      =   4185
  13.    Top             =   1170
  14.    Width           =   4305
  15.    Begin VB.TextBox txtEnd 
  16.       Height          =   285
  17.       Left            =   1200
  18.       TabIndex        =   5
  19.       Top             =   960
  20.       Width           =   1215
  21.    End
  22.    Begin VB.TextBox txtStart 
  23.       Height          =   285
  24.       Left            =   1200
  25.       TabIndex        =   2
  26.       Top             =   360
  27.       Width           =   1215
  28.    End
  29.    Begin VB.CommandButton cmdQuit 
  30.       Caption         =   "Quit"
  31.       Height          =   495
  32.       Left            =   2760
  33.       TabIndex        =   1
  34.       Top             =   840
  35.       Width           =   1215
  36.    End
  37.    Begin VB.CommandButton cmdReport 
  38.       Caption         =   "Run Report"
  39.       Default         =   -1  'True
  40.       Height          =   495
  41.       Left            =   2760
  42.       TabIndex        =   0
  43.       Top             =   240
  44.       Width           =   1215
  45.    End
  46.    Begin MSComDlg.CommonDialog cdOpenReport 
  47.       Left            =   600
  48.       Top             =   1200
  49.       _version        =   65536
  50.       _extentx        =   847
  51.       _extenty        =   847
  52.       _stockprops     =   0
  53.       defaultext      =   "rpt"
  54.       dialogtitle     =   "Select Crystal Report"
  55.       filter          =   "Reports (*.rpt)|*.rpt|All Files (*.*)|*.*"
  56.       initdir         =   "c:\vb\report"
  57.    End
  58.    Begin VB.Label Label2 
  59.       Caption         =   "End Year:"
  60.       Height          =   255
  61.       Left            =   240
  62.       TabIndex        =   4
  63.       Top             =   960
  64.       Width           =   855
  65.    End
  66.    Begin VB.Label Label1 
  67.       Caption         =   "Start Year:"
  68.       Height          =   255
  69.       Left            =   240
  70.       TabIndex        =   3
  71.       Top             =   360
  72.       Width           =   855
  73.    End
  74.    Begin Crystal.CrystalReport CrystalReport1 
  75.       Left            =   0
  76.       Top             =   1200
  77.       _extentx        =   741
  78.       _extenty        =   741
  79.       _stockprops     =   0
  80.       reportfilename  =   ""
  81.       destination     =   0
  82.       windowleft      =   100
  83.       windowtop       =   100
  84.       windowwidth     =   490
  85.       windowheight    =   300
  86.       windowtitle     =   ""
  87.       windowborderstyle=   2
  88.       windowcontrolbox=   -1  'True
  89.       windowmaxbutton =   -1  'True
  90.       windowminbutton =   -1  'True
  91.       copiestoprinter =   1
  92.       printfilename   =   ""
  93.       printfiletype   =   0
  94.       selectionformula=   ""
  95.       groupselectionformula=   ""
  96.       connect         =   ""
  97.       username        =   ""
  98.    End
  99. End
  100. Attribute VB_Name = "frmAuthors"
  101. Attribute VB_Creatable = False
  102. Attribute VB_Exposed = False
  103. Option Explicit
  104.  
  105. Private Sub cmdQuit_Click()
  106.     End
  107. End Sub
  108.  
  109. Private Sub cmdReport_Click()
  110.     Dim selCriteria As String
  111.     Static saveDir As String
  112.     
  113.     'Check for errors in the input year boxes
  114.     If (Val(txtStart.Text) > Val(txtEnd.Text)) And Val(txtEnd.Text) Then
  115.         MsgBox "Start year must be before End year."
  116.         Exit Sub
  117.     End If
  118.     If Val(txtStart.Text) And Val(txtStart.Text) < 1850 And Val(txtStart.Text) > Year(Now) Then
  119.         MsgBox "Please enter a start year in the range 1850 to " & Year(Now)
  120.         Exit Sub
  121.     End If
  122.     If Val(txtEnd.Text) And Val(txtEnd.Text) < 1850 And Val(txtEnd.Text) > Year(Now) Then
  123.         MsgBox "Please enter an ending year in the range 1850 to " & Year(Now)
  124.         Exit Sub
  125.     End If
  126.     
  127.     'Get the file to print using Common Dialog
  128.     cdOpenReport.InitDir = saveDir
  129.     cdOpenReport.ShowOpen
  130.     
  131.     'Let's be nice and "remember" the directory for the next use
  132.     saveDir = cdOpenReport.FileName
  133.     
  134.     If Len(cdOpenReport.FileName) Then
  135.         'Adding the data to the control
  136.         CrystalReport1.Destination = 0 'To Window
  137.         CrystalReport1.ReportFileName = cdOpenReport.FileName
  138.         If Len(txtStart.Text) And Len(txtEnd.Text) Then
  139.             'Year range entered
  140.             selCriteria = "{Authors.Year Born} in " & txtStart.Text & " to " & txtEnd.Text
  141.         ElseIf Len(txtStart.Text) And Len(txtEnd.Text) = 0 Then
  142.             'Only starting year selected
  143.             selCriteria = "{Authors.Year Born} >= " & txtStart.Text
  144.         ElseIf Len(txtStart.Text) = 0 And Len(txtEnd.Text) Then
  145.             selCriteria = "{Authors.Year Born} <= " & txtEnd.Text
  146.         Else
  147.             'Both boxes are emtpy; don't limit range
  148.             selCriteria = ""
  149.         End If
  150.         CrystalReport1.SelectionFormula = selCriteria
  151.     
  152.         'Run the report
  153.         CrystalReport1.Action = 1
  154.     Else
  155.         'User pressed Cancel in Common Dialog
  156.         MsgBox "No report file selected."
  157.     End If
  158. End Sub
  159.  
  160. Private Sub Form_Load()
  161.     'Move the form to the lower right of screen
  162.     Me.Move Screen.Width - 1.1 * Me.Width, Screen.Height - 1.25 * Me.Height
  163. End Sub
  164.  
  165.